

package com.maoshi.shop.service;

import com.alipay.api.AlipayApiException;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.maoshi.shop.bean.bo.PayInfoBo;
import com.maoshi.shop.bean.bo.RefundInfoBo;
import com.maoshi.shop.common.enums.PayType;
import com.maoshi.shop.bean.pay.PayInfoDto;
import com.maoshi.shop.bean.pay.RefundInfoDto;
import org.springframework.http.ResponseEntity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;

/**
 * 支付相关
 */
public interface PayManagerService {


	/**
	 * 进行支付
	 * @param httpResponse
	 * @param payInfo
	 * @return
	 * @throws WxPayException
	 * @throws IOException
	 */
	ResponseEntity<?> doPay(HttpServletResponse httpResponse, PayInfoDto payInfo) throws WxPayException, IOException;


	/**
	 * 校验支付结果，并返回支付单号
	 * @param request
	 * @param payType
	 * @param xmlData
	 * @return
	 * @throws UnsupportedEncodingException
	 * @throws WxPayException
	 * @throws AlipayApiException
	 */
	PayInfoBo validateAndGetPayInfo(HttpServletRequest request, PayType payType, String xmlData) throws UnsupportedEncodingException, WxPayException, AlipayApiException;


	/**
	 * 主动查单，看看订单是否已经支付
	 * @param payNo 支付单号
	 * @return
	 */
	PayInfoBo getPayInfo(PayType payType,String payNo);


	/**
	 * 退款
	 */
	public void doRefund(RefundInfoDto refundInfo);



	/**
	 * 校验支付结果，并返回支付单号
	 * @param request
	 * @param payType
	 * @param xmlData
	 * @return
	 * @throws UnsupportedEncodingException
	 * @throws WxPayException
	 * @throws AlipayApiException
	 */
	RefundInfoBo validateAndGetRefundInfo(HttpServletRequest request, PayType payType, String xmlData) throws UnsupportedEncodingException, WxPayException, AlipayApiException;



}
